package datalookin.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.whu.zj.MyApplication;
import com.whu.zj.R;

import org.w3c.dom.Text;

import java.util.ArrayList;
import java.util.List;

import datalookin.dto.StationAllDataDto;
import datalookin.dto.WaterPlantMainDataDto;

/**
 * 所有的水厂
 * Created by Administrator on 2016/3/12.
 */
public class AllPlantMonitorAdapter extends BaseAdapter {

    List<WaterPlantMainDataDto> waterPlantMainDataDtos = new ArrayList<WaterPlantMainDataDto>();

    public void setWaterPlantMainDataDtos(List<WaterPlantMainDataDto> waterPlantMainDataDtos) {
        this.waterPlantMainDataDtos = waterPlantMainDataDtos;
    }

    @Override
    public int getCount() {
        return waterPlantMainDataDtos.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null)
        {
            viewHolder = new ViewHolder();
            convertView = View.inflate(MyApplication.share(), R.layout.item_plantrealdata,null);
            viewHolder.tv_plant = (TextView) convertView.findViewById(R.id.id_tv_plantName);
            viewHolder.tv_time = (TextView) convertView.findViewById(R.id.id_tv_time);
            viewHolder.tv_zhuodu = (TextView) convertView.findViewById(R.id.id_tv_zhuodu);
            viewHolder.tv_yulu = (TextView) convertView.findViewById(R.id.id_tv_yulu);
            viewHolder.tv_gongshui = (TextView) convertView.findViewById(R.id.id_tv_gongshui);

            convertView.setTag(viewHolder);
        }
        else
        {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        WaterPlantMainDataDto waterPlantMainDataDto = waterPlantMainDataDtos.get(position);
        viewHolder.tv_plant.setText(waterPlantMainDataDto.getWaterPlantName());
        viewHolder.tv_time.setText(waterPlantMainDataDto.getTime());
        viewHolder.tv_zhuodu.setText(waterPlantMainDataDto.getTurbidity());
        viewHolder.tv_yulu.setText(waterPlantMainDataDto.getChlorine());
        viewHolder.tv_gongshui.setText(waterPlantMainDataDto.getSupplyFlow());

        return convertView;
    }


    public static class ViewHolder
    {
        public TextView tv_plant;
        public TextView tv_time;
        public TextView tv_zhuodu;
        public TextView tv_yulu;
        public TextView tv_gongshui;
    }
}
